
public class HashingAVL extends Hashing
{  
    public HashingAVL( int M, boolean verbose )
    {
        super(M,verbose);
    }

    @Override
    public void insert(int x)
    {
        int i = super.funcionHash(x);
        if(hashes[i] == null) {
            hashes[i] = new NodoHashAVL(x);
        }
        else
        {
            if(Hashing.verbosa)
            {
                System.out.println("Se ha detectado una colisión al insertar el " + x);
            }
            hashes[i].insert(x);
        }
    }

    public @Override
    boolean search(int x)
    {
        int id = funcionHash(x);
        if(hashes[id] == null)
            return false;
        else
            return hashes[id].search(x);
    }

    @Override
    public void imprimir()
    {
        System.out.println("imprimiendo los numeros de la tabla de hash");
        for(int i = 0; i<this.hashes.length; i++)
        {
            if(this.hashes[i] !=null)
            {
                System.out.print("\n |"+i+((i<10)?" ":"")+"|");
                this.hashes[i].imprimir();
            }
        }
        System.out.println("\n");
    }
}
